{% extends 'base.html' %}
{% load staticfiles %}
{% block mycss %}
    <link rel="stylesheet" type="text/css" href="{% static 'js/plugins/queryCity/css/cityLayout.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/lq.datetimepick.css' %}"/>
    {% block mycss1 %}{% endblock %}
{% endblock %}

{% block middle %}
    <div class="middle">
        <div class="wp">
            <a href="/"><img class="fl" src="{% static 'images/logo1.png' %}"/></a>
            <h1>我的谷粒教育网</h1>
        </div>
    </div>
{% endblock %}

{% block content %}
    <section>
        <div class="wp">
            <ul class="crumbs">
                <li><a href="/">首页</a>></li>
                <li><a href="{% url 'users:user_info' %}">个人中心</a>></li>
                <li>{% block breach %}{% endblock %}</li>
            </ul>
        </div>
    </section>

    <section>
        <div class="wp list personal_list">
            <div class="left">
                <ul>
                    <li {% if request.path == '/users/user_info/' %}class="active2"{% endif %}><a
                            href="{% url 'users:user_info' %}">个人资料</a></li>
                    <li {% if request.path == '/users/user_course/' %}class="active2"{% endif %}><a
                            href="{% url 'users:user_course' %}">我的课程</a></li>
                    <li {% if request.path|slice:':16' == '/users/user_love' %}class="active2"{% endif %}><a
                            href="{% url 'users:user_love_org' %}">我的收藏</a></li>
                    <li {% if request.path == '/users/user_message/' %}class="active2"{% endif %}><a
                            href="{% url 'users:user_message' %}" style="position: relative;">我的消息</a></li>
                </ul>
            </div>
            {% block right %}

            {% endblock %}
        </div>
    </section>

    {% block dialog %}
        <div class="dialog" id="jsDialog">
            <div class="resetpwdbox dialogbox" id="jsResetDialog">
                <h1>修改密码</h1>
                <div class="close jsCloseDialog"><img src="{% static 'images/dig_close.png' %}"/></div>
                <div class="cont">
                    <form id="jsResetPwdForm" autocomplete="off">
                        <div class="box">
                            <span class="word2">新&nbsp;&nbsp;密&nbsp;&nbsp;码</span>
                            <input type="password" id="pwd" name="password1" placeholder="6-20位非中文字符"/>
                        </div>
                        <div class="box">
                            <span class="word2">确定密码</span>
                            <input type="password" id="repwd" name="password2" placeholder="6-20位非中文字符"/>
                        </div>
                        <div class="error btns" id="jsResetPwdTips"></div>
                        <div class="button">
                            <input id="jsResetPwdBtn" type="button" value="提交"/>
                        </div>
                        <input type='hidden' name='csrfmiddlewaretoken' value='DaP7IUKm9FA9nELA9YUlYYWpyIDdCiIP'/>
                        <input type='hidden' name='csrfmiddlewaretoken' value='799Y6iPeEDNSGvrTu3noBrO4MBLv6enY'/>
                    </form>
                </div>
            </div>

            <div class="dialogbox changeemai1 changephone" id="jsChangeEmailDialog">
                <h1>修改邮箱</h1>
                <div class="close jsCloseDialog"><img src="{% static 'images/dig_close.png' %}"/></div>
                <p>请输入新的邮箱地址</p>
                <form id="jsChangeEmailForm" autocomplete="off">
                    <div class="box">
                        <input class="fl change_email" name="email" id="jsChangeEmail" type="text"
                               placeholder="输入重新绑定的邮箱地址">
                    </div>
                    <div class="box">
                        <input class="fl email_code" type="text" id="jsChangeEmailCode" name="code"
                               placeholder="输入邮箱验证码">
                        <input class="getcode getting" type="button" id="jsChangeEmailCodeButton" value="获取验证码">
                    </div>
                    <div class="error btns change_email_tips" id="jsChangeEmailTips">请输入...</div>
                    <div class="button">
                        <input class="changeemai_btn" id="jsChangeEmailButton" type="button" value="完成"/>
                    </div>
                    <input type='hidden' name='csrfmiddlewaretoken' value='DaP7IUKm9FA9nELA9YUlYYWpyIDdCiIP'/>
                    <input type='hidden' name='csrfmiddlewaretoken' value='799Y6iPeEDNSGvrTu3noBrO4MBLv6enY'/>
                </form>
            </div>
        </div>
        <div class="bg" id="dialogBg"></div>
    {% endblock %}
{% endblock %}

{% block footer %}{% endblock %}

{% block myjs %}
    <script src='{% static 'js/plugins/jquery.upload.js' %}' type='text/javascript'></script>
    <script src="{% static 'js/validate.js' %}" type="text/javascript"></script>
    {% block user %}
        <script src="{% static 'js/deco-user.js' %}"></script>
    {% endblock %}
    <script>
        $(function () {
            $('#jsChangeEmailCodeButton').click(function () {
                var email = $('#jsChangeEmail').val()
                $.ajax({
                    type: 'POST',
                    url: '{% url 'users:user_change_email' %}',
                    data: {
                        email: email,
                        csrfmiddlewaretoken: '{{ csrf_token }}'
                    },
                    success: function (callback) {
                        alert(callback.msg)
                    }
                })
            })
            $('#jsChangeEmailButton').click(function () {
                var email = $('#jsChangeEmail').val()
                var code = $('#jsChangeEmailCode').val()
                $.ajax({
                    type: 'POST',
                    url: '{% url 'users:user_reset_email' %}',
                    data: {
                        email: email,
                        code: code,
                        csrfmiddlewaretoken: '{{ csrf_token }}'
                    },
                    success: function (callback) {
                        if (callback.status == 'ok') {
                            alert(callback.msg)
                            window.location.href = '{% url 'users:user_login' %}'
                        } else {
                            alert(callback.msg)
                        }
                    }
                })
            })
        })
    </script>
    {% block myjs1 %}{% endblock %}
{% endblock %}